package com.topc.participant.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topc.base.exception.Asserts;
import com.topc.base.model.PageParams;
import com.topc.base.model.PageResult;
import com.topc.base.utils.PageUtils;
import com.topc.participant.model.dto.QueryGroupDto;
import com.topc.participant.model.po.GroupInfo;
import com.topc.participant.mapper.GroupInfoMapper;
import com.topc.participant.model.vo.GroupShowVo;
import com.topc.participant.service.IGroupInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 组信息 服务实现类
 * </p>
 *
 * @author Gogoing
 */
@Slf4j
@Service
public class GroupInfoServiceImpl extends ServiceImpl<GroupInfoMapper, GroupInfo> implements IGroupInfoService {

    @Override
    public PageResult<GroupShowVo> searchInfoByPage(PageParams pageParams, QueryGroupDto saveGroupDto) {
        Page page  = this.getBaseMapper().searchInfoByPage(pageParams.page(),saveGroupDto);
        return PageUtils.pageToResult(page);
    }

    @Override
    public void updateInfoById(Long id, int status) {
            GroupInfo groupInfo = new GroupInfo();
            groupInfo.setId(id);
            groupInfo.setStatus(status);
            boolean update =this.updateById(groupInfo);
            if(!update) Asserts.fail("更新失败");
    }
}
